package com.realife.eson.common.util.network;

import com.realife.eson.common.asserts.AssertNP;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @version V1.0
 * @author: guangcheng
 * @date: 2022/5/22 2:59
 * @description:
 */
@Slf4j
@Data
@Component
public class MeResponse {

    @Autowired
    HttpUtils httpUtils;


    /**
     *
     * @param requestWay 请求方式
     * @param preUrl 前置路径
     * @param pathVarList 路径变量值
     * @param uriMap ?拼接参数对
     * @param body 请求体对象
     * @param formParam 表单参数
     * @param headers 头信息
     * @return
     */
    public String getContent(String requestWay, String preUrl, List<Object> pathVarList, Map<String, Object> uriMap,
                             Object body, Map<String, String> formParam, Map<String, String> headers) {
        //
        String fullPath = IpUtil.getFullPath(preUrl, pathVarList, uriMap);
        //
        String bodyParam = AssertNP.bodyParam(body, "");
        //
        return httpUtils.request(requestWay, fullPath, bodyParam, formParam, headers);
    }

}

